<?php
namespace Home\Controller;
use Think\Controller;
use Org\SequenceNumber;

class IndexController extends Controller {

    public function index(){

        $Model = M();

        $sql = "SELECT a.litpic FROM __PICTURE__ AS a LEFT JOIN __PICTURE_CATEGORY__ AS b ON a.cid = b.id WHERE b.key = 'index-banner' ORDER BY a.rank DESC";

        $banner = $Model->query($sql);

        $bannerReturn = array();
        foreach($banner as $v){

            $bannerReturn[] = array(
                'imgUrl' => C('PICDOMAIN').C('PICPATH').$v['litpic']
            );
        }

        $sql = "SELECT a.litpic, a.name FROM __PICTURE__ AS a LEFT JOIN __PICTURE_CATEGORY__ AS b ON a.cid = b.id WHERE b.key = 'index-list' ORDER BY a.rank DESC";

        $list = $Model->query($sql);

        $listReturn = array();
        foreach($list as $k=>$v){

            $listReturn[] = array(
                'name'      => $v['name'],
                'imgUrl'    => C('PICDOMAIN').C('PICPATH').$v['litpic']
            );
        }

        $jsonReturn = array(
            'banner'    => $bannerReturn,
            'vedio'     => $listReturn
        );

        $this->ajaxReturn($jsonReturn);
    }

    public function moko(){

    }
}